/*
 * @Description:
 * @Author:
 * @Date: 2024-10-28 23:17:02
 * @LastEditTime: 2024-11-02 11:17:57
 * @LastEditors: XXX
 */
import type { Module, Store as VuexStore, CommitOptions, DispatchOptions } from 'vuex'
import type { PermissionState } from "./state";
import type { RootState } from '../../index'

import { state } from "./state";
import { actions, type Actions } from './actions';
import { mutations, type Mutations } from './mutations';

export type { PermissionState }

export type PermissionStore<S = PermissionState> = Omit<VuexStore<S>, 'getters' | 'commit' | 'dispatch'> & {
  commit<K extends keyof Mutations, P extends Parameters<Mutations[K]>[1]> (
    key: K,
    payload: P,
    options?: CommitOptions
  ): ReturnType<Mutations[K]>
} & {
  dispatch<K extends keyof Actions> (
    key: K,
    payload: Parameters<Actions[K]>[1],
    options?: DispatchOptions
  ): ReturnType<Actions[K]>
}

export const store: Module<PermissionState, RootState> = {
  state: state,
  mutations: mutations,
  actions: actions
}
